from . import db

class Product(db.Model):
    __tablename__ = 'products'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(100), nullable=False)  # 产品名称
    url = db.Column(db.String(255), nullable=False)  # 产品图片URL
    specification = db.Column(db.String(255), nullable=False)
    category = db.Column(db.String(255), nullable=False)
    quality = db.Column(db.String(255), nullable=False)
    # 显式使用反引号转义 desc 列
    desc = db.Column('desc', db.Text, nullable=False)  # 产品详情

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}